#include <FileNotFoundException.hpp>
#include <AppStream.hpp>

#ifndef _CLASSMODELINGDISKSTREAM_
#define _CLASSMODELINGDISKSTREAM_

namespace Modeling {

class DiskStream : public Modeling::AppStream
{
public:
	virtual ~DiskStream();
	DiskStream(std::string name, std::string mode);

	size_t write(Modeling::Scene* scene);
	size_t write(Modeling::Animation* animation);
	size_t write(Modeling::Root* root);
	size_t write(Modeling::Mesh* mesh);
	size_t write(Modeling::Camera* camera);
	size_t write(Modeling::Light* light);
	size_t write(Modeling::Material* material);
	size_t write(Modeling::Map* map);

	size_t read(Modeling::Scene* scene);
	size_t read(Modeling::Animation* animation);
	size_t read(Modeling::Root* root);
	size_t read(Modeling::Mesh* mesh);
	size_t read(Modeling::Camera* camera);
	size_t read(Modeling::Light* light);
	size_t read(Modeling::Material* material);
	size_t read(Modeling::Map* map);

protected:
	FILE* file;
	Modeling::Root* root;

	size_t writeChildren(Modeling::Node* node);
	size_t castNode(Modeling::Node* node);
	size_t writeMaterials(Modeling::Root* root);
	size_t readMaterials(Modeling::Root* root);

	virtual size_t read(int* value)=0;
	virtual size_t read(unsigned int* value)=0;	
	virtual size_t read(float* value)=0;
	virtual size_t read(std::string* str)=0;
	virtual size_t read(Vector3ui* vector)=0;
	virtual size_t read(Vector3f* vector)=0;
	virtual size_t read(Vector2f* vector)=0;
	virtual size_t read(Modeling::RGBf* rgb)=0;
	virtual size_t read(Matrix4f* matrix)=0;

	virtual size_t write(int value)=0;
	virtual size_t write(unsigned int value)=0;
	virtual size_t write(float value)=0;
	virtual size_t write(std::string str)=0;
	virtual size_t write(Vector3ui vector)=0;
	virtual size_t write(Vector3f vector)=0;
	virtual size_t write(Vector2f vector)=0;
	virtual size_t write(Modeling::RGBf rgb)=0;
	virtual size_t write(Matrix4f matrix)=0;
};

}// namespace Modeling

#endif
